package com.ovt.doorbell.payment.service.manager;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ovt.doorbell.payment.common.exception.OVTRuntimeException;
import com.ovt.doorbell.payment.dao.UserPermissionDao;
import com.ovt.doorbell.payment.dao.vo.UserPermission;
import com.ovt.doorbell.payment.service.exception.ServiceErrorCode;
import com.ovt.doorbell.payment.service.exception.ServiceException;

@Service
public class UserPermissionManagerImpl
{
    @Autowired
    private UserPermissionDao userPermissionDao;
    
    public void saveUserPermission(UserPermission userPermission) throws ServiceException 
    {
        try
        {
            this.userPermissionDao.save(userPermission);
        }
        catch (OVTRuntimeException e)
        {
            throw new ServiceException(ServiceErrorCode.DB,
                    "Failed to save user permission!", e);
        }
    }
    
    public void deleteUserPermission(int userId, int permId) throws ServiceException 
    {
        try
        {
            this.userPermissionDao.delete(userId, permId);
        }
        catch (OVTRuntimeException e)
        {
            throw new ServiceException(ServiceErrorCode.DB,
                    "Failed to delete user permission!", e);
        }
    }
    
}
